<?php
namespace Common\Model;

use Common\Model\BaseModel;

class BulidingModel extends BaseModel
{
    protected $tableName = 'building';

    public function addBuliding($post)
    {

        $ret = array('status' => '', 'info' => '');
        $data = $this->returnData($post);
        if ($this->create($data)) {
            $res = null !== $data['id'] ? $this->save($data) : $this->add($data);
            if (false !== $res) {
                $ret['status'] = true;
                $ret['info'] = "Success";
            } else {
                $ret['status'] = false;
                $ret['info'] = $this->getDbError();
            }
        } else {
            $ret['status'] = false;
            $ret['info'] = $this->getError();
        }

        return $ret;
    }

    public function returnData($post)
    {
        $return['building_id'] = !empty($post['building_id']) ? intval($post['building_id']) : null;
        $return['building_name'] = !empty($post['building_name']) ? addslashes($post['building_name']) : '';

        return $return;
    }
    public function getBuliding($field = "*")
    {
        $res = $this->field($field)->select();
        return $res;
    }
    
}